import { http } from '@/utils'

// 获取频道列表
export const getChannelListAPI = () => {
  return http({
    method: 'GET',
    url: '/channels'
  })
}

// 创建文章
export const createArticleAPI = (data) => {
  return http({
    method: 'POST',
    url: '/mp/articles?draft=false',
    data
  })
}

// 更新文章
export const updateArticleAPI = (data) => {
  return http({
    method: 'PUT',
    url: `/mp/articles/${data.id}?draft=false`,
    data
  })
}

// 获取文章列表
export const getArticleListAPI = (params) => {
  return http({
    method: 'GET',
    url: '/mp/articles',
    params
  })
}

// 删除文章
export const delArticleAPI = (id) => {
  return http({
    method: 'DELETE',
    url: `/mp/articles/${id}`
  })
}

// 根据 id 获取文章详情
export const getArticleByIdAPI = (id) => {
  return http({
    method: 'GET',
    url: `/mp/articles/${id}`
  })
}